package com.cbank.dao;

import com.cbank.domain.AboutUsBanner;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface AboutUsBannerDao {
    public static final String ALL="id,view_id,create_time,update_time,about_us_id,url,title";

    @Select("select "+ALL+" from about_us_banner where id = #{id}")
    AboutUsBanner getById(Integer id);

    @Select("select "+ALL+" from about_us_banner where about_us_id = #{aboutUsId}")
    List<AboutUsBanner> getListByAboutUsId(Integer aboutUsId);

    @Select("select "+ALL+" from about_us_banner where view_id = #{viewId}")
    AboutUsBanner getByViewId(String viewId);

    @Insert("insert into about_us_banner (view_id,about_us_id,url,title) values(#{viewId},#{aboutUsId},#{url},#{title})")
    @Options(useGeneratedKeys = true)
    void insert(AboutUsBanner aboutUsBanner);

    @Update("update about_us_banner set about_us_id=#{aboutUsId},url=#{url},title=#{title} where id = #{id}")
    void update(AboutUsBanner aboutUsBanner);
}
